wayland: Add request focus support via gtk_shell
authorJonas Ådahl <jadahl@gmail.com>
Tue, 8 Mar 2016 09:03:06 +0000 (17:03 +0800)
committerJonas Ådahl <jadahl@gmail.com>
Thu, 10 Mar 2016 04:31:15 +0000 (12:31 +0800)
A gtk_surface.present request was added to gtk_surface which takes
timestamp from some input event, and uses that timestamp to figure out
whether the window can be presented or not. If we don't have a
timestamp, we should just give up instead of making up our own,
otherwise we might steal someones focus.

https://bugzilla.gnome.org/show_bug.cgi?id=763037

gdk/wayland/gdkwindow-wayland.c
gdk/wayland/protocol/gtk-shell.xml

index bf2dcd0068ebd15aec35786ead1b8ca62b4e71f1..707b2dcb438a2b9c79627c50f8665a23a9d6c530 100644 (file)
@@ -2093,6 +2093,19 @@ static void
 gdk_wayland_window_focus (GdkWindow *window,
                           guint32    timestamp)
 {
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+
+  if (!impl->display_server.gtk_surface)
+    return;
+
+  /* We didn't have an event to fetch a time from, meaning we have nothing valid
+   * to send. This should rather be translated to a 'needs-attention' request or
+   * something.
+   */
+  if (timestamp == GDK_CURRENT_TIME)
+    return;
+
+  gtk_surface1_present (impl->display_server.gtk_surface, timestamp);
 }
 
 static void
index aa9993d66cef0351e463b6561ce9f1418a00a586..2e750ea0f1dc0a567edddf1a9885ad8ac357c4f5 100644 (file)
 
     <request name="set_modal"/>
     <request name="unset_modal"/>
+
+    <request name="present">
+      <arg name="time" type="uint"/>
+    </request>
   </interface>
 
 </protocol>